import {View, Button, Text, Image, ScrollView, Radio} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';
import * as T from '../types';
import './tab.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';
type ITopProps = T.IProps & T.ITopProps;
//@ts-ignore
@connect<Partial<ITopProps>, T.ITopState & {selectIndex: number}>(store2Props, actions)
export default class Info extends Component<Partial<ITopProps>, T.ITopState & {selectIndex: number}> {
  constructor(props: ITopProps) {
    super(props);
    this.state = {
      selectIndex: 0,
    };
  }

  render() {
    const {
      actions: {action},
    } = this.props;
    const tabList = [
      {value: undefined, label: '全部明细'},
      {value: 1, label: '仅获取'},
      {value: 0, label: '仅使用'},
    ];
    const {selectIndex} = this.state;
    return (
      <View className="rechargeHistoryNavBar">
        {tabList.map((e, i) => (
          <View
            className={`navbarItem navbarItem-${selectIndex === i ? 'select' : ''}`}
            key={i}
            onClick={() => {
              this.setState({
                selectIndex: i,
              });
              action.commonChange('main.list', []);
              action.commonChange('main.searchParams', {
                type: e.value,
                pageNum: 0,
                pageSize: 10,
              });
              action.page(true);
            }}
          >
            {e.label}
          </View>
        ))}
      </View>
    );
  }
}
